import { request } from '../request';


/**
 * Refresh token
 *
 * @param refreshToken Refresh token
 */
export function fetchRefreshToken(refreshToken: string) {
  return request<Api.Auth.LoginToken>({
    url: '/refreshToken',
    method: 'post',
    data: {
      refreshToken
    }
  });
}


/** Get user info */
export function fetchGetUserInfo() {
  return request<Api.Auth.UserInfo>({ url: '/userInfo' });
}
/**
 * 登录
 * @param userName - 用户名
 * @param password - 密码
 */
export function fetchLogin(userName: string, password: string,code:string,uuid:string,rememberMe?:boolean) {
  return request({
    url:'/login',
    data: { userName, password,code,uuid,rememberMe:rememberMe!! },
    method: 'POST',
  });
}


/**
 * 获取图形验证码
 * @param phone - 手机号
 * @returns - 返回boolean值表示是否发送成功
 */
export function fetchImgCode() {
  return request<any>({url:'/captchaImage',method:"get"});
}

export function fetchLogout() {
  return request<string>({
    url:'/logout',method:"put"
  });
}


export function fetchGetUserMenu(){
  return request<Api.ApiRoute.Route>({ url: '/routers' });
}



/**
 *  更新用户头像
 * @param formData 文件form
 * @returns 路径
 */
export function fetchUpdateUserAvatar(formData:FormData){
	return request<string>({
    url:'/userInfo/avatar',data:formData,method:"PUT"
  });
}

/**
 *  更新用户信息
 * @param userInfo  用户信息
 * @returns status
 */
export function fetchUpdateUserInfo(userInfo:SysAuth.UserInfo){
  return request<string>({
    url:'/userInfo',data:userInfo,method:"PUT"
  });
}

/**
 *  更新密码
 * @param pw
 * @returns
 */
export function fetchUpdatePW(pw:any){
  return request<string>({
    url:'/userInfo/pw',data:pw,method:"PUT"
  });
}
